package com.hooper.exception;

import com.hooper.emun.ResultCodeEnum;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2023/03/29/13:48
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BusinessException extends RuntimeException {

    private static final int DEFAULT_FAIL_CODE = 201;
    private Integer code;
    private String description;

    public BusinessException(Integer code, String message) {
        super(message);
        this.code = code;
    }

    public BusinessException(String message) {
        super(message);
        this.code = DEFAULT_FAIL_CODE;
    }

    public BusinessException(Integer code, String message,String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ResultCodeEnum code) {
        super(code.getMessage());
        this.code = code.getCode();
    }
    public BusinessException(ResultCodeEnum code,String description) {
        super(code.getMessage());
        this.code = code.getCode();
        this.description = description;
    }

}
